<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		canvas{
			border: 1px solid #000;
			 
		}
	</style>
</head>
<body>
	<canvas id="canvas" width="800" height="500"></canvas>
	<script type="text/javascript">
		//得到标签
		var canvas = document.getElementById("canvas");
		//上下文
		var ctx = canvas.getContext("2d");

		var image = new Image();
		image.src = "images/blood.png";
		image.onload = function(){
			var num = 0;
			var t= setInterval(function(){
				ctx.clearRect(0, 0, 1231, 1231);
				num++;
				if(num == 30){
					clearInterval(t);
				}
				var row = parseInt(num / 5);
				var col = num % 5;

				ctx.drawImage(image, 325 * col , 138*row,325,138,100,100,325,138);
			}, 30);
		}
	</script>
</body>
</html>